/*
 * Skill.cpp
 *
 *  Created on: Jan 12, 2009
 *      Author: sez
 */

#include "Skill.h"

#include <Xml/Xml.h>
#include <Xml/XmlPath.h>

Skill::Skill(const QString &title)
	: TitledData(title)
{
}

Skill::Skill(const Skill &rhs)
	: TitledData(rhs.title())
{
        keyAbility = rhs.keyAbility;
        summary = rhs.summary;
}

Skill::~Skill()
{
}

Skill &Skill::operator=(const Skill &rhs)
{
        keyAbility = rhs.keyAbility;
        summary = rhs.summary;
        return *this;
}

void Skill::saveToXml() const
{
    Xml xml(XmlPath(XmlPath::RACIAL_BASE, XmlPath::safeDataPathName(title())));
    xml.appendTag("Title", title());
    appendTag(xml, "KeyAbility", keyAbility);
    xml.appendTag("Summary", summary);
    xml.serializeXml();
}

void Skill::loadFromXml()
{
    Xml xml(XmlPath(XmlPath::RACIAL_BASE, XmlPath::safeDataPathName(title())));
    xml.deserializeXml();
    setTitle(xml.value("Title"));
    keyAbility = value<DndData::Ability>(xml, "KeyAbility");
    summary = xml.value("Summary");
}
